import {
	Message
} from 'element-ui'
const fileSize = (file) => {
	const isLt2M = file.size / 1024 / 1024 < 100;
	if (!isLt2M) {
		Message.error('上传文件大小不能超过 100MB!');
	}
	return isLt2M
}

const fileImg = (file) => {
	const isJpeg = file.type === 'image/jpeg';
	const isJpg = file.type === 'image/jpg';
	const isPng = file.type === 'image/png';
	const isBmp = file.type === 'image/bmp';
	const isLt2M = file.size / 1024 / 1024 < 100;
	if (!isLt2M) {
		Message.error('上传文件大小不能超过 100MB!');
		return isLt2M
	}
	if (isJpeg || isJpg || isPng || isBmp) {} else {
		Message.error('上传图片格式错误！');
		return false
	}
}

const filenotmp4 = (file) => {  // information仅聊天页面用到
	const ismp4 = file.type == 'video/mp4';
	const isJpeg = file.type === 'image/jpeg';
	const isJpg = file.type === 'image/jpg';
	const isPng = file.type === 'image/png';
	const isLt2M = file.size / 1024 / 1024 < 100;
	if (!isLt2M) {
		Message.error('上传文件大小不能超过 100MB!');
		return isLt2M
	};
	if (isJpeg || isJpg || isPng) {
		Message.error('此功能不支持上传图片资源！');
		return false
	};
	// if(ismp4){
	// 	Message.error('上传文件格式错误！');
	// 	return false
	// }
}

export default {
	fileSizenum: 100,
	fileSize: fileSize,
	fileImg: fileImg,
	filenotmp4: filenotmp4

}